import os
import sys

# 请在此输入您的代码

n, m = map(int, input().split())

a = [[0] * (m+1) for _ in range(n+1)]

#we are at (x,y)
x, y = 1, 1
value = 1
a[x][y] = value

while True:
  #right
  while y + 1 <= m and a[x][y+1] == 0:
    y += 1
    value += 1
    a[x][y] = value


  #down
  while x + 1 <= n and a[x + 1][y] == 0:
    x += 1
    value += 1
    a[x][y] = value

  #left
  while y - 1 >= 1 and a[x][y - 1] == 0:
    y -= 1
    value += 1
    a[x][y] = value

  #up
  while x - 1 >= 1 and a[x - 1][y] == 0:
    x -= 1
    value += 1
    a[x][y] = value

  if value == n * m:
    break

r, c = map(int, input().split())
print(a[r][c])
